<%--
    Document   : home
    Created on : Oct 23, 2011, 5:06:42 PM
    Author     : Group 106
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" errorPage="error.jsp"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.List" %>
<%@page import="com.aptech.model.RealEstateType" %>
<%@page import="com.aptech.model.RealEstate" %>
<%@page import="com.aptech.model.User" %>
<%@page import="com.aptech.model.realEstateInfo" %>
<%@page import="com.aptech.DAO.realEstateTypeDAO" %>
<%@page import="com.aptech.DAO.realEstateStyleDAO" %>
<%@page import="com.aptech.DAO.realEstateDAO" %>
<%@page import="com.aptech.DAO.userDAO" %>
<%@page import="com.aptech.DAO.postHistoryDAO" %>

<%@ taglib prefix="page" uri="/WEB-INF/tlds/phantrang.tld" %>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <link rel="stylesheet" href="CSS/css.css" />
       <%-- <link rel="stylesheet" href="CSS/css_header.css" /> --%>
        <link rel="stylesheet" href="CSS/mn_left.css" />
        <link rel="stylesheet" href="CSS/mn_search.css" />
        <link rel="stylesheet" href="CSS/css_realEstateInfor.css" />
       <%-- <link rel="stylesheet" href="CSS/css_footer.css" /> --%>
       <link href="CSS/msh_style.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="CSS/gallery_style.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <%
                User objUser = null;
                String userID = "";
                int realEstateID;
                ArrayList<RealEstateType> listRealStateType = new ArrayList<RealEstateType>();
                if (request.getSession().getAttribute("user") != null) {
                    realEstateTypeDAO objRealEstateTypeDAO = new realEstateTypeDAO();
                    realEstateStyleDAO objRESDAO = new realEstateStyleDAO();
                    realEstateDAO objRealEstateDAO = new realEstateDAO();
                    objUser = (User) request.getSession().getAttribute("user");
                    userID = objUser.getUserID() + "";
                    listRealStateType = new ArrayList<RealEstateType>();
                    listRealStateType = objRealEstateTypeDAO.getAllRealEstateType();
    %>
    <body>

        <div id="wrap">
            <%@include file="header.jsp" %>
           
            <div class="clear"></div><!--End .clear-->
            <div id="main">
                <div id="left_sidebar">
                    <%@include file="leftSidebar.jsp" %>
                </div><!--End #left_sidebar-->
                <div id="content">
                    <%
                        if (request.getParameter("realEstateID") != null) {
                            RealEstate realEstate = null;
                            realEstateID = Integer.parseInt(request.getParameter("realEstateID"));
                            realEstate = objRealEstateDAO.getRealEstateInfo(realEstateID);
                            if(realEstate!=null){
                    %>
                    <table width="100%" border="0" style="padding-top: 10px">
                        
                        <tr>
                            <td width="150" height="397" valign="top">
                                <img src="Imgs/realEstate_Imgs/<%=realEstate.getImage() %>" width="150" height="200" />
                            </td>
                            <td width="540" valign="top"><table width="100%" border="0"  cellspacing="3">
                                    <tr>
                                        <td colspan="2" height="30" bgcolor="</h3>" align="center"><h3><%=realEstate.getRealEstateTitle() %></h3></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" height="30" align="left">
                                            <u> <h3>Real Estate Information</h3> </u>
                                            <br/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="30%" bgcolor="#220ace" height="23">&nbsp;&nbsp;City:</td>
                                        <td width="70%" bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getCity() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Street:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getStreet() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Price:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getPrice() %>000 VND</td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;NoOfBedrooms:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getNoOfBedrooms() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;NoOfBathrooms:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getNoOfBathrooms() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Type:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=objRealEstateTypeDAO.getRealEstateTypeByID(realEstate.getRealEstateTypeID()) %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Area:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getArea() %> m2</td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Orientation:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getOrientation() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;ExtraFacilitiesAvailable:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getExtraFacilitiesAvailable() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;ModesOfTransport:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getModesOfTransport() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;WithFurniture:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getWithFurniture() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;ModeOfPayment:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getModeOfPayment() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Deposit:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getDeposit() %>000 VND</td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Negotiable:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getNegotiable() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Description:</td>
                                        <td bgcolor="#220ace">&nbsp;&nbsp;<%=realEstate.getDescription() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Style:</td>
                                        <td bgcolor="#220ace" >&nbsp;&nbsp;<%=objRESDAO.getRealEstateStyleByID(realEstate.getRealEstateStyleID()) %></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" height="30" align="left">
                                            <u><h3>Contacts</h3></u>
                                            <br/>
                                        </td>
                                    </tr>
                                    <%
                                    postHistoryDAO objPHDAO = new postHistoryDAO();
                                    int userID1 = objPHDAO.getUserIDByPost(realEstate.getRealEstateID());
                                        userDAO objUserDAO = new userDAO();
                                        User objUser1 = objUserDAO.getUserByID(userID1);
                                    %>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Name: </td>
                                        <td bgcolor="#220ace" >&nbsp;&nbsp;<%=objUser1.getUserName() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Email </td>
                                        <td bgcolor="#220ace" >&nbsp;&nbsp;<%=objUser1.getUserEmail() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Address: </td>
                                        <td bgcolor="#220ace" >&nbsp;&nbsp;<%=objUser1.getUserAddress() %></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#220ace" height="23">&nbsp;&nbsp;Phone </td>
                                        <td bgcolor="#220ace" >&nbsp;&nbsp;<%=objUser1.getUserPhone() %></td>
                                    </tr>
                                </table></td>
                        </tr>
                    </table>
                    <%
                            }else{
                            %>
                   <table width="700" height="400" border="0">
                        <tr>
                            <td align="center">
                                Khong tim thay du lieu ban can tim!
                            </td>
                        </tr>
                    </table>
                    <%
                        } } else {
                    %>
                    <table width="700" height="400" border="0">
                        <tr>
                            <td align="center">
                                San pham ma ban tim khong co.
                            </td>
                        </tr>
                    </table>
                    <%                                            }
                    %>
                </div><!--End #content-->
            </div><!--End #main-->
                        <div class="cleaner_with_height">&nbsp;</div><!--End .clear-->
                        <div id="msh_footer_panel" style="width: 942px;">
    Copyright © 2011 <a href="index.html">Ha Noi - Aptech</a> | <a href="home.jsp" target="_parent">Website My Sweet Home</a> by <a href="home.jsp" target="_blank">Group 106</a></div>
        </div><!--End #wrap-->
        <div class="clear_with_heght"></div><!--End .clear-->
    </body>
    <%
                } else {
                    response.sendRedirect("login.jsp");
                }
    %>
</html>